<template>
  <section class="app-main">
    <router-view v-slot="{ Component }">
      <transition name="fade-transform" mode="out-in">
        <keep-alive>
          <component :is="Component" />
        </keep-alive>
      </transition>
    </router-view>
  </section>
</template>

<script setup>
// 使用 keep-alive 和 transition 实现页面切换动画和缓存
</script>

<style lang="scss" scoped>
.app-main {
  position: relative;
  height: calc(100vh - 50px - 34px); // 减去导航栏和标签栏的高度
  width: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  background-color: var(--bg-color);
}

// 过渡动画
.fade-transform-enter-active,
.fade-transform-leave-active {
  transition: all 0.3s;
}

.fade-transform-enter-from {
  opacity: 0;
  transform: translateX(30px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(-30px);
}
</style> 